disp('fmdlf');

omega = 0.2;
Nc = 40;
disp(fn_f(omega,Nc));

Num = 2000;
vn = -1000:1000;
vg = zeros(1,length(vn));
vf1 = zeros(1,length(vn));
vf2 = zeros(1,length(vn));

for i = 1:length(vn)
    n = vn(i);
    vg(i) = fn_g(n, Num);
    vf1(i) = fn_f(2*pi/Num*n, Num/2);
    vf2(i) = fn_f(-2*pi/Num*n, Num/2-1);
end

close(figure(1));
figure(1);
plot(vn,imag(vg),'-ro');
hold on;
plot(vn,pi*ones(size(vn)),'b--');
plot(vn,-pi*ones(size(vn)),'b--');

close(figure(2));
figure(2);
plot(vn, real(vf1),'-ro');
hold on;
plot(vn, imag(vf1),'-bo');
hold on;
plot(vn,real(vf2),'-g*');
hold on;
plot(vn,imag(vf2),'-y*');


Num = 200;
nq = floor(Num*(rand() - 1/2));

LHS = 0;
for nx = 1:Num
    LHS = LHS + 1/Num*exp(-1j*2*pi/Num*nq*nx)*fn_g(nx,Num);
end

RHS = 1/nq;

disp(abs(RHS - LHS));

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

function res = fn_g(x,Num)

res = fn_f(2*pi/Num*x,Num/2) - fn_f(-2*pi/Num*x,Num/2-1);

end

function res = fn_f(omega,Nc)

vn = 1:Nc;

res = sum(exp(1j*omega*vn)./vn);

end